import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login/index.vue'
import Layout from '../views/Layout/index.vue'
// 引入封装好的导航列表
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'layout',
    component: Layout,
    children: [
      {
        path: '/',
        name: 'login',
        component: Login
      },
      // 路由用到异步的加载
      {
        path: '/home',
        name: 'Home',
        component: () => import('../views/Home/index.vue')
      },
      {
        path: '/mine',
        name: 'Mine',
        component: () => import('../views/Mine/index.vue')
      },
      {
        path: '/search',
        name: 'Search',
        component: () => import('../views/Search/index.vue')
      }
    ]
  },
  {
    path: '/MusicDetails/:id',
    name: 'MusicDetails',
    component: () => import('../views/login/MusicDetails.vue')
  },
  {
    // 多传三个参数过去
    path: '/player/:id',
    name: 'Player',
    component: () => import('../views/Player/index.vue')
  },
  // 加载更多页面路由
  {
    path: '/djmore/:id',
    name: 'djmore',
    component: () => import('../views/DJmore/index.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  linkActiveClass: 'active'
})

export default router
